<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body>

<?php

	include("inc/joomlaInt.php");
	include("inc/inc_configuration.php");
	include("inc/inc_icq.php");
	
	ini_set( 'display_errors', true );
	error_reporting( E_ALL );
	
	$cQ = "	SELECT 
				lt.teamId,
				t.name,
				lt.leagueId, 
				l.name AS lname,
				l.type
			FROM 
				$tbl_combinations c, 
				$tbl_teams t, 
				$tbl_leagues l, 
				$tbl_lt lt
			WHERE 
				c.userId=$jUser AND 
				c.active=1 AND 
				c.teamId=t.id AND 
				lt.leagueId=l.id AND
				lt.teamId=t.id ";
			
	//echo $cQ;
	$cQe = mysql_query($cQ);


	$canz = mySQL_num_rows($cQe);

	if ($canz>0)
	{
		for ($ic = 0; $ic < $canz; $ic++)
		{
			$t1IdO = mysql_fetch_object($cQe);
			$t1Id = $t1IdO->teamId;
			$l1n = $t1IdO->lname;
			$l1id = $t1IdO->leagueId;
			$type = $t1IdO->type;
			
			if ($type==1)
			{
				$matches=	"SELECT m1.id AS mId
									
								FROM $tbl_combinations c1,  $tbl_matches m1, $tbl_teams t1, $tbl_teams t2
								
								WHERE
								((m1.free=1) OR (m1.free=2)) AND
								(m1.leagueId=$l1id) AND
								((c1.userId=$jUser AND
								c1.active=1 AND 
								m1.homeT=c1.teamId AND
								m1.homeT=$t1Id AND
								c1.teamId=t1.id AND
								m1.guestT=t2.id)
								OR
								(c1.userId=$jUser AND
								c1.active=1 AND 
								m1.guestT=c1.teamId AND 
								m1.guestT=$t1Id AND
								c1.teamId=t2.id AND
								m1.homeT=t1.id))
								ORDER BY spieltag
							";
			}
			else
			{
				$matches=	"SELECT m1.id AS mId
									
								FROM $tbl_combinations c1,  $tbl_matches m1, $tbl_teams t1, $tbl_teams t2
								
								WHERE
								((m1.free=1) OR (m1.free=2)) AND
								(m1.leagueId=$l1id) AND
								((c1.userId=$jUser AND
								c1.active=1 AND 
								m1.homeT=c1.teamId AND
								m1.homeT=$t1Id AND
								c1.teamId=t1.id AND
								m1.guestT=t2.id)
								OR
								(c1.userId=$jUser AND
								c1.active=1 AND 
								m1.guestT=c1.teamId AND 
								m1.guestT=$t1Id AND
								c1.teamId=t2.id AND
								m1.homeT=t1.id))
								ORDER BY spieltag
							";
			}
			
			$matchese=mysql_query($matches);
			
			$anz=0;
			$a="";
			
			while ($row=mysql_fetch_object($matchese)
			{
				$mid=$row->mId;
				
				$anz= $anz + get_anz_forderungen_ungelesen($jUser,$mid);
				//$a.=$anz . " - ";
			}
			
			if ($anz>0)
			{
				$r="<font color='$rot'>Ungelesene Forderungen</font>";
			}
			else
			{
				$r="<font color='$gruen'>Neue Forderungen</font>";
			}
			
			echo $r;
			
			
		}
	}



?>

</body>
</html>